package com.scqkxx.gamebox.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class VerifyUtils {

    //由于Android边编译边生成的原理，将匹配字符串放入全局，作为静态变量可以提高效率
    public static Pattern emailPattern = Pattern.compile("\\w+([-+.]\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");


    /**
     * 验证邮箱
     * @param email
     * @return
     */
    public static boolean isEmail(String email) {
        if (null == email || "".equals(email)) return false;
        Matcher m = emailPattern.matcher(email);
        return m.matches();
    }

    /**
     * 判断手机格式是否正确
     */
    public static boolean isMobile(String mobiles) {
        Pattern p = Pattern.compile("^((13[0-9])|(15[^4,\\D])|(17[0-9])|(18[0-9]))\\d{8}$");//新加所有18段 17段
        Matcher m = p.matcher(mobiles);
        return m.matches();
    }

}
